<?php
$conn = mysql_connect("localhost", "root", "643313") or die(mysql_error());
mysql_select_db("regist_sys");

$sql_degree = "SELECT * FROM degree";
$result_degree = mysql_query($sql_degree, $conn) or die(mysql_error());

$sql_dep = "SELECT * FROM department";
$result_dep = mysql_query($sql_dep,$conn) or die(mysql_error());
?>
<div id="main">
	<form action="reg_finish.php">
		<fieldset>
			<legend>Student Registration</legend>
			<table width="400" border="0" cellspacing="0" cellpadding="0">
				<tr>
					<td>
						<p>
							<label>ID</label>
						</p>
					</td>
					<td><p><input type="text" name="id"/></p></td>
				</tr>
				<tr>
					<td>
						<p>
							<label>First name</label>
						</p>
					</td>
					<td><p><input type="text" name="firstName"/></p>
					</td>
				</tr>
				<tr>
					<td>
						<p>
							<label>Last name</label>
						</p>
					</td>
					<td><p><input type="text" name="lastName" /></p></td>
				</tr>
				<tr>
					<td>
						<p>
							<label>Degree</label>
						</p></td>
					<td><p><select name="degree">
					<?php
					while ($row = mysql_fetch_assoc($result_degree)) {
						foreach ($row as $deg => $value) {
							print "<option>$value</option> \n";
						}
					}
					?>
					</select></p>
					</td>
				</tr>
				<tr>
					<td>
						<p>
							<label>Department</label>
						</p>
					</td>
					<td><p><select name="department">
					<?php
					while ($row = mysql_fetch_assoc($result_dep)) {
						print "<option>";
						print $row["department"];
						print "</option> \n";
					}
					?>
					</select></p>
					</td>
				</tr>
				<tr>
					<td><p>
						<button type="submit">Submit</button>
						<button type="reset">Reset</button></p>
					</td>
				</tr>
			</table>
		</fieldset>
	</form>

</div>
